#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
map<ll,ll> mp;
ll a[6];
ll check()
{
    bool f2 = 0, f3 = 0;
    for (ll i = 1; i <= 6;i++)
    {
        if(mp[i]==5)
        {
            return 1;
        }
        if(mp[i]==4)
        {
            return 2;
        }
        if(mp[i]==2)
            f2=1;
        if(mp[i]==3)
            f3 = 1;
    }
    if(f2&&f3)
    return 3;
    bool g4 = 1, g5 = 1;
    for(ll i=2;i<=5;i++)
    {
        if(mp[i]==0)
            g4 = 0;
    }
    if(g4)
        return 4;
    for(ll i=1;i<=5;i++)
    {
        if(mp[i]==0)
            g5 = 0;
    }
    if(g5)
        return 5;
    ll q3=0,q2=0,q1=0;
    for(ll i=1;i<=6;i++)
    {
        if(mp[i]==3)
            q3++;
        if(mp[i]==1)
        q1++;
        if(mp[i]==2)
            q2++;
    }
    if(q3==1) return 6;
    if(q2==2) return 7;
    if(q2==1&&q1==3) return 8;
    return 9;
}
void solve()
{
    
    for(ll i=1;i<=5;i++)
    {
        cin >> a[i];
        mp[a[i]]++;
    }
    ll grade = check();
    if(grade==7)
        cout << "3 4 9\n";
    if(grade==8)
    cout<<"3 13 18\n";
    if(grade == 6)
        cout << "2 4 9\n";
    if(grade==1)
    cout<<"0 0 1\n";
    if(grade ==2 )
        cout << "1 1 6\n";
    if(grade==3)
        cout << "1 1 6\n";
   
    //cout << grade << endl;
}
int main()
{
    int t = 1;
    cin >> t;
    while(t--)
    {
        mp.clear();

        solve();
    }
   return 0;
}
